package com.shrcl.engineerprocess.domain.impl;

import com.shrcl.engineerprocess.domain.TSCServiceType;
import com.shrcl.engineerprocess.domain.TSCServiceTypeCategory;
import com.shrcl.engineerprocess.domain.TSCServiceTypeCriteria;
import edu.fudan.mylang.pf.query.HQLBasedPagedQueryCriteria;
import org.hibernate.Query;

public class TSCServiceTypeCriteriaImpl extends HQLBasedPagedQueryCriteria<TSCServiceType> implements TSCServiceTypeCriteria {
  private TSCServiceTypeCategory category;
  
  public TSCServiceTypeCategory getCategory() {
    return this.category;
  }
  
  public TSCServiceTypeCriteria setCategory(final TSCServiceTypeCategory category) {
    this.category = category;
    return this;			
    
  }
  
  private String name;
  
  public String getName() {
    return this.name;
  }
  
  public TSCServiceTypeCriteria setName(final String name) {
    this.name = name;
    return this;			
    
  }
  
  protected String buildHQLFrom() {
    return " from com.shrcl.engineerprocess.domain.impl.TSCServiceTypeImpl this ";
  }
  
  protected String buildHQLBody() {
    String hql = "where 1 = 1 ";
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getCategory()) ){
    	hql += " and ((this.category) = (:category))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getName()) ){
    	hql += " and (this.name  LIKE :name)" ;
    }
    return hql;
    
  }
  
  public void initOrderBys() {
    
  }
  
  protected void fillParameter(final Query query) {
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getCategory())){
    	query.setParameter("category",getCategory()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getName())){
    	query.setParameter("name",getName()) ;
    }			
    
  }
  
  protected Boolean isDistinct() {
    return false;
  }
  
  public TSCServiceTypeCriteriaImpl() {
    initOrderBys();
  }
}
